import { Injectable } from "@nestjs/common";
import { InjectRepository } from "@nestjs/typeorm";

import {TagsEntity} from './tag.entity'
import { Repository } from "typeorm";
@Injectable()
export class TagService{
    constructor(
        @InjectRepository(TagsEntity)
        private readonly tagService:Repository<TagsEntity>
    ){}

    async find(){
        return await this.tagService
            .createQueryBuilder('tag')
            .getMany()
    }
    async findByIds(ids){
        return await this.tagService.findByIds(ids)
    }

    async add(tag){
        return await this.tagService.save(tag)
    }

    async remove(tagId){
        return await this.tagService.delete(tagId);
    }

    async update(tag){
        return await this.tagService.update(tag.tagId,tag)
    }
}